import 'package:flutter/material.dart';
import 'package:shenling_wuliu/component/content.dart';
import 'package:shenling_wuliu/utils/token.dart';

class SystemWidget extends StatefulWidget {
  const SystemWidget({super.key});

  @override
  State<SystemWidget> createState() => _SyatemWidgetState();
}

class _SyatemWidgetState extends State<SystemWidget> {

   showConfirmDialog() {
    return showDialog(
        context: context,
        builder: (context) {
          return AlertDialog(
              // title: const Text('温馨提示'),
              content: const Text('确定要删除该房屋吗？'),
              actions: [
                TextButton(
                    onPressed: () {
                      Navigator.pop(context);
                    },
                    child: const Text('取消', style: TextStyle(color: Colors.red),)),
                TextButton(
                    onPressed: () {
                      TokenManager().removeToken();
                      Navigator.popUntil(context, ModalRoute.withName('/'));
                    },
                    child: const Text('确定'))
              ]);
        });
 }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('系统设置',style: TextStyle(fontSize: 15),),
        centerTitle: true,
      ),
      body: Container(
        margin: EdgeInsets.all(20),
        color: const Color.fromARGB(255, 242, 238, 238),
        padding: EdgeInsets.all(10),
        child: Column(
          children: [
            Container(
              color: Colors.white,
              width: MediaQuery.of(context).size.width,
              margin: EdgeInsets.all(10),
              padding: EdgeInsets.all(10),
              child: Column(
              children: [
                ContentItem(title: "换绑手机"),
                SizedBox(height: 10,),
                ContentItem(title: "修改密码"),
                SizedBox(height: 10,),
                ContentItem(title: "消息通知设置"),
                SizedBox(height: 10,),
                ContentItem(title: "修改密码"),
                SizedBox(height: 10,),
                ContentItem(title: "清理缓存"),
              ],
            ),
            ),
            SizedBox(height: 20,),
            Container(
              color: const Color.fromARGB(255, 242, 238, 238),
              width: MediaQuery.of(context).size.width,
              margin: EdgeInsets.all(10),
              padding: EdgeInsets.all(10),
              child: ElevatedButton(
                style: ButtonStyle(
                  backgroundColor: WidgetStateProperty.all(Colors.white),
                ),
                onPressed: (){
                showConfirmDialog();
              }, child: Text('退出',style: TextStyle(fontSize: 15),textAlign: TextAlign.center,)
              ),
            )
          ],
        ),
      ),
    );
  }
}